class ManagersController < ApplicationController
before_filter :find_manager, :except => [:index, :new, :create]
  
  def index
    @managers = Manager.find(:all, :order => "name")
  end

  def show
  end
  

  
  def new
    @managers = Manager.new
  end

  def create
    @managers = Manager.new(params[:manager])

    if @managers.save 
      @current_manager  = @manager
      session[:manager] = @manager.id 

      flash[:notice] = "Successfully Registered"
      redirect_to :action => "show", :id => @manager.id
    else
      render :action => "new"
    end
  end
  

  
  def edit
  end

  def update
    if @manager.update_attributes(params[:manager])
      flash[:notice] = 'User successfully updated.'
      redirect_to :action => "show", :id => @manager.id
    else
      render :action => "edit"
    end
  end

  def destroy
    @user.destroy
    flash[:notice] = 'User successfully annihilated'
    redirect_to :action => "index"
  end
  
  
  private

  def find_manager
    @manager = Manager.find(params[:id])
  end
end
